<?php
namespace App\Utils\WechatSdk;

class SendRequestOperator{

	/**
	 * [sendRequest 使用guzzle发送http请求，并将请求结果封装为ResponseModel对象]
	 * @param  Client $client  [guzzle http client]
	 * @param  string $method  [http请求方法]
	 * @param  string $url     [http请求地址]
	 * @param  Array $options  [http请求可选项]
	 * @return ResponseModel   [返回值]
	 */
	public static function sendRequest($client, $method, $url, $options){
		$result = new ResponseModel();
		try {
			$response = $client->request($method, $url, $options);
		} catch (ConnectException $e) {
			$result->code = ResponseCodeModel::$HttpConnectException;
			return $result;
		}
		$result->code = ResponseCodeModel::$HttpSuccess;
		$result->data = $response->getBody()->getContents();
		return $result;
	}

}